# import tkinter as tk

# window = tk.Tk()
# window.title('hello thinter')
# height= window.winfo_screenheight()
# width= window.winfo_screenwidth()
# window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
# #创建一个空列表
# theLB = tk.Listbox(window)
# theLB.pack()

# # 往列表里添加数据
# for item in ["国家", "省", "市", "区"]:
#         theLB.insert("end", item)

# window.mainloop()


# 获取选择的值


# import tkinter as tk

# def A():
#     param = theLB.get(theLB.curselection())
#     print("选中的值",param)

# window = tk.Tk()
# window.title('hello thinter')
# height= window.winfo_screenheight()
# width= window.winfo_screenwidth()
# window.geometry('400x200+%d+%d'%((width-400)/2,(height-200)/2))
# #创建一个空列表
# theLB = tk.Listbox(window)
# theLB.pack()

# # 往列表里添加数据
# for item in ["国家", "省", "市", "区"]:
#         theLB.insert("end", item)

# tk.Button(window,text="获取选中的值",command=A).pack()
# window.mainloop()






# 删除选中的值

import tkinter as tk

def A():
    param = theLB.get(theLB.curselection())
    print("选中的值",param)

window = tk.Tk()
window.title('hello thinter')
height= window.winfo_screenheight()
width= window.winfo_screenwidth()
window.geometry('400x300+%d+%d'%((width-400)/2,(height-300)/2))
#创建一个空列表
theLB = tk.Listbox(window)
theLB.pack()

# 往列表里添加数据
for item in ["国家", "省", "市", "区"]:
        theLB.insert("end", item)


tk.Button(window,text="获取选中的值",command=A).pack()
tk.Button(window,text="删除选中的值",command=lambda x=theLB: x.delete("active")).pack()
window.mainloop()